/**
 * Created by oneminute on 8/12/14.
 */

var lz = require("../utils/modules")();
var moment = require("moment");

function MessageCode(_opts) {
    lz.Persistent.call(this, _opts);
    if (!_opts) _opts = {};
    var now = moment();
    this.__properties.pushArray([
        { name: "smsid", value: _opts.smsid || "" },
        { name: "code", value: _opts.code || "" },
        { name: "timestamp", value: now.format(lz.Config.datetimeFormatLong) },
        { name: "phone", value: _opts.phone || "" },
        { name: "type", value: _opts.type || "register" }
    ]);
    this.__initProperties();
    this.__collection = lz.Config.db.arango.codes;
    this.__aql = lz.Config.db.arango.aqls.GET_OBJECT_BY_PROPERTY;
}

require("util").inherits(MessageCode, lz.Persistent);

exports = module.exports = MessageCode;
